1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#![allow(non_camel_case_types, non_snake_case)]
use crate::co;
use crate::decl::*;
use crate::kernel::privs::*;
use crate::prelude::*;
use crate::user::ffi;
impl user_Hprocess for HPROCESS {}
/// This trait is enabled with the `user` feature, and provides methods for
/// [`HPROCESS`](crate::HPROCESS).
///
/// Prefer importing this trait through the prelude:
///
/// ```no_run
/// use winsafe::prelude::*;
/// ```
pub trait user_Hprocess: kernel_Hprocess {
/// [`SetUserObjectInformation`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setuserobjectinformationw)
/// function.
///
/// # Safety
///
/// The `pv_info` type varies according to `index`. If you set it wrong,
/// you're likely to cause a buffer overrun.
unsafe fn SetUserObjectInformation<T>(&self,
index: co::UOI,
pv_info: &mut T,
) -> SysResult<()>
{
bool_to_sysresult(
ffi::SetUserObjectInformationW(
self.ptr(),
index.raw(),
pv_info as *mut _ as _,
std::mem::size_of::<T>() as _,
),
)
}
/// [`WaitForInputIdle`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-waitforinputidle)
/// function.
fn WaitForInputIdle(&self, milliseconds: u32) -> SysResult<SuccessTimeout> {
match unsafe { ffi::WaitForInputIdle(self.ptr(), milliseconds) } {
0 => Ok(SuccessTimeout::Success),
0x0000_0102 => Ok(SuccessTimeout::Timeout),
_ => Err(GetLastError()),
}
}
}